home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagn_r.zip / POINTERS.SWG / 0004_LL_TEST.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  77 lines

  1. {
  2. This is the test Program that I drew up to test the Procedures in Pete
  3. Davis' LinkList.Pas posted in the previous message.  It could be a little more
  4. dressed up but it does work and offers some insight, I think, into the use of
  5. Pointers and linked lists:  note that I ran a little manual test to locate a
  6. designated Pointer in a given list.  Here it is:
  7. }
  8.  
  9. Uses
  10.   Crt, LinkList;
  11.  
  12. Var
  13.   AList1, AList2, AList3, AList4 : Data_Ptr;
  14.   ANum : DataType;
  15.   Count : Integer;
  16.  
  17. begin
  18.   ClrScr;
  19.   Init_List(AList1);
  20.   Writeln('Results of inserting links at the beginning of a list: ');
  21.   For Count := 1 to 20 do
  22.   begin
  23.     ANum := Count;
  24.     Write(' ',ANum);
  25.     Insert_begin(AList1, ANum); {pay out first link (1) to last (20) like}
  26.                                 {a fishing line With #-cards.  You end up}
  27.   end;                          {with 20 in your hand going up to 1}
  28.   Writeln;
  29.   Writeln('Watch - Last link inserted is the highest number.');
  30.   Writeln('You are paying out the list like reeling out a fishing line,');
  31.   Writeln('Foot 1, Foot 2, Foot 3, etc. - last one is Foot 20.');
  32.   Writeln('Now, mentally reel in the line to the fourth number.');
  33.   Writeln(' ',alist1^.Next_Rec^.Next_Rec^.Next_Rec^.OurData);
  34.   Writeln;
  35.   Writeln('Now insert one additional number at beginning of list');
  36.   begin
  37.     ANum := 21;
  38.     Insert_begin(AList1,ANum);
  39.   end;
  40.   Writeln(' ',AList1^.OurData);
  41.    Writeln;
  42.  
  43.  
  44.   Init_List(Alist2);
  45.   Writeln('Results of Inserting links in turn at the end of a list: ');
  46.   For Count := 1 to 20 do
  47.   begin
  48.     ANum := Count;
  49.     Write(' ',ANum);
  50.     Insert_end(Alist2,ANum);
  51.   end;
  52.   Writeln;
  53.   Writeln('note, just the reverse situation of the process above.');
  54.   Writeln('Reel in the line to the fourth number.');
  55.   Writeln(' ',Alist2^.Next_Rec^.Next_Rec^.Next_Rec^.OurData);
  56.           {We inserted at the end so we are now going out toward the 20}
  57.  
  58.  
  59.  
  60.  Init_List(Alist3);
  61.  Writeln('Results of Inserting links in turn in orDER');
  62.  For Count := 1 to 20 do
  63.  begin
  64.    Anum := Count;
  65.    Write(' ',ANum);
  66.    Insert_In_order(Alist3,ANum);
  67.  end;
  68.  Writeln;
  69.  Writeln(' ',Alist3^.Next_Rec^.Next_Rec^.Next_Rec^.OurData);
  70.  
  71. end.
  72. {
  73.         In Case anybody missed Pete Davis' Linklist Unit in the previous
  74. message but may have it in her/his library (PNL002.ZIP) what I was asking is
  75. some help With writing code to test the Procedure DELETE_HERE which is the last
  76. Procedure in the Unit.
  77. }